<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui"
      xmlns:ui="http://java.sun.com/jsf/facelets">
	
	<h:head>
		<title>Cadastro de Usuário</title>
	</h:head> 

	<ui:composition template="/templates/interna.xhtml">
		<ui:define name="titulo">		 
			Cadastro de Usuário
		</ui:define>
		<ui:define name="corpo">
		<h:form id="cadastro">
			<h:messages />
			<h:inputHidden value="#{usuarioBean.usuario.codigo}" />
			<h:inputHidden value="#{usuarioBean.usuario.ativo}" />
			<h:inputHidden value="#{usuarioBean.destinoSalvar}" />
			
			<h:panelGrid columns="2">
				<h:outputLabel value="Nome:" for="nome" />
				<p:inputText id="nome" label="Nome" value="#{usuarioBean.usuario.nome}" required="true" size="30" maxlength="30"
							 requiredMessage="Você não tem nome???">
							 <f:validateLength minimum="10"  maximum="30"/>
				</p:inputText>
				
				<h:outputLabel value="Data de Nascimento:" for="nascimento" />
				<p:calendar effect="explode" id="nascimento" label="Data Nascimento" value="#{usuarioBean.usuario.nascimento}" >
							<f:convertDateTime dateStyle="medium"/>
				</p:calendar>

				<h:outputLabel value="Celular:" for="celular" />
				<p:inputText id="celular" label="Celular" value="#{usuarioBean.usuario.celular}" required="true" size="10" />
							
				<h:outputLabel value="e-Mail:" for="email" />
				<h:panelGroup>
					<p:inputText value="#{usuarioBean.usuario.email}" label="e-Mail" id="email" size="50" maxlength="50" required="true"
								 validatorMessage="e-Mail invalido!">
								 <f:validateRegex pattern="[a-zA-Z0-9\-\_\.]+@[a-zA-Z0-9\-\_\.]+"/>
				    </p:inputText>
					<h:message for="email"/>
				</h:panelGroup>
				
								
				<h:outputLabel value="Idioma:" for="idioma" />
				<p:selectOneMenu id="idioma" value="#{usuarioBean.usuario.idioma}">
					<f:selectItem itemValue="pt_BR" itemLabel="Português"/>
					<f:selectItem itemValue="en_US" itemLabel="Inglês"/>
					<f:selectItem itemValue="es_ES" itemLabel="Espanhol"/>
				</p:selectOneMenu>
				
				<h:outputLabel value="Login:" for="login" />
				<p:inputText id="login" label="Login" value="#{usuarioBean.usuario.login}" required="true" size="15" maxlength="15" 
							 validatorMessage="Login deve ter no minimo 5 e no maximo 15 caracteres e só pode ser os simbulos '.' e '_'.">
							 <f:validateRegex pattern="([a-z]|[0-9]|[:]|[_]){5,15}" />
				</p:inputText>
				
				<h:outputLabel value="Senha:" for="senha" />
				<p:password feedback="true" goodLabel="Senha boa" weakLabel="Senha Fraca" 
						    id="senha" label="Senha" value="#{usuarioBean.usuario.senha}" 
						    required="true" size="10" maxlength="10" redisplay="true" 
						    promptLabel="Digite sua senha"/>
			
				<h:outputLabel value="Confiramar Senha:" for="confirmasenha" />
				<p:password feedback="true" goodLabel="Senha boa" weakLabel="Senha Fraca" 
							id="confirmasenha" label="Confirmar Senha" value="#{usuarioBean.confirmaSenha}" 
							required="true" size="10" maxlength="10" redisplay="true" 
							promptLabel="Confirme sua senha"/>
			</h:panelGrid>
			
			<p:commandButton action="#{usuarioBean.salvar}" value="Salvar" ajax="false"/>
			
		</h:form>
		<hr />
		</ui:define>
	</ui:composition>
		
 
</html>
